'use strict';

const Service = require('egg').Service;

class SeatService extends Service {
    /* 列表查看 */
    async seatList (tableName,id) {
        const result = await this.app.mysql.get(tableName,{id});
        return {result};
    };

    /* 座位预约 */
    async selectSeat(tableName,uid, fid, sid,today) {
        const result = await this.app.mysql.insert(tableName,{uid, fid, sid,today})
        return {result}
    };

    /* 切换座位 */
    async change(tableName,id, fid, sid) {
        // 切换座位根据查找
        const row = {
            id: id,
            fid: fid,
            sid: sid,
          };
        // const result = await this.app.mysql.insert(tableName,{uid, fid, sid,today})
        const result = await this.app.mysql.update(tableName, row);
        return {result}
    };

    /* 预约座位查看 */
    async seatOrderList (tableName,uid) {
        const result = await this.app.mysql.get(tableName,{uid});
        return {result};
    };

    /* 设置常用座位 */
    async regular(tableName,uid, fid, sid) {
        const result = await this.app.mysql.insert(tableName,{uid, fid, sid})
        return {result}
    };

}

module.exports = SeatService;